<template>
  <el-backtop :bottom="60" :right="60" @click.native="handleClick">
    <div title="回到顶部" class="backtop-style">
      <i class="fa fa-arrow-up"></i>
      <span v-if="showText" class="backtop-text">顶部</span>
    </div>
  </el-backtop>
</template>

<script>
export default {
  name: "BackTop",
  data() {
    return {
      showText: false
    };
  },
  methods: {
    handleClick() {
      this.showText = true;
      setTimeout(() => {
        this.showText = false;
      }, 1000);
    }
  }
};
</script>

<style scoped>
.backtop-style {
  height: 100%;
  width: 100%;
  background-color: #f2f5f6;
  box-shadow: 0 1px 0 0;
  border-radius: 12px;
  text-align: center;
  line-height: 40px;
  color: #167df0;
  position: relative;
}

.backtop-text {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #999;
  transition: opacity 0.3s;
}
</style>